473,467 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Paragraph Packing

Page <URL:http://www.merlyn.demon.co.uk/js-quick.htm> now contains code
to pack text into multiple paragraphs of given right margin (the nominal
range is from 1 to nearly Infinity).
function Pak(F) { var S = F.Code.value, L = +F.Len.value, J, Re
S = S.replace(/(\r?\n){2,}/g, "\u0000").replace(/(\r?\n)/g, " ")
S = S.replace(/\s+/g, " ").split("\u0000")
if (L<1) L = F.Len.value = 1
Re = new RegExp("(.{1," + L + "}) ", "g")
J = S.length ; while (J--)
S[J] = (S[J].replace(/^\s+/, "")+" ").replace(Re, "$1\n")
F.Code.value = S.join("\n") }
F.Code is the I/O textarea; Code.L gives the margin.

The input paragraph separator is an empty line or lines.

It works in my IE4 ; any comment, particularly in respect of recognising
line-ends in non-Windows systems ?

Also - is anything wrong with using \u0000 as a marker?
The feature can be used to normalise badly-posted plain text, for more
comfortable reading.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 11 '05 #1
2 1684
Dr John Stockton wrote:
[...]
It works in my IE4 ; any comment, particularly in respect of recognising
line-ends in non-Windows systems ?


Seems to work fine in Safari 1.0.3, it does not recognise new lines in
IE 5.2 (Mac). I'll mess around with and see if I can find the
appropriate character - maybe \u0000 is the issue.
[...]
--
Rob
Dec 13 '05 #2
JRS: In article <439e9bbb$0$3672$5a62ac22@per-qv1-newsreader-
01.iinet.net.au>, dated Tue, 13 Dec 2005 20:00:27 local, seen in
news:comp.lang.javascript, RobG <rg***@iinet.net.auau> posted :
Dr John Stockton wrote:
[...]
It works in my IE4 ; any comment, particularly in respect of recognising
line-ends in non-Windows systems ?


Seems to work fine in Safari 1.0.3, it does not recognise new lines in
IE 5.2 (Mac). I'll mess around with and see if I can find the
appropriate character - maybe \u0000 is the issue.


Could be; for test purposes one can use the uncontentious but rare #
instead; literally or as \u0023 (?).

But I'd look closely at the two (\r?\n) ... It may be necessary to do
them in two stages each, first for \r\n and second for \r|\n.
Thanks for looking.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: nobull | last post by:
Google won't let me post this as a follow-up but lynch@agere.com (lynto) wrote in message news:<503469eb.0407271148.7ee4b0ca@posting.google.com>... > Does anyone have an algorithm for packing...
2
by: gbb0330 | last post by:
Hi all I need some advice. the daily packing number will be used to match a box with its label. the guys in the warehouse will get a list of items to pack. they will find the item - put it...
1
by: gbb0330 | last post by:
hi guys -the code (all capital letters) generates daily packing number, it is in the on click event of a command button that moves to the next record. dpkn is unbound control - i use it to...
2
by: FMorales | last post by:
Hello all, quick hopefully easy question. Here goes. I've started on the Art Of Assembly tutorial(s) (http://webster.cs.ucr.edu/Page_asm/0_ArtOfAsm.html) and got to the sample projects and kinda...
18
by: Edward Diener | last post by:
Is the packing alignment of __nogc classes stored as part of the assembly ? I think it must as the compiler, when referencing the assembly, could not know how the original data is packed otherwise....
1
by: Gajendra | last post by:
How does the byte packing and the byte alignment work in VC++ compiler? What is the effect of #pragma pack(n) on the alignment and byte packing for example while using the structur struc double...
9
by: fraz | last post by:
Does anyone have code to solve a 3-d bin packing problem in php? I am trying to solve the issue of packing various sized rectangular shaped objects into boxes of three different sizes so as to use...
1
by: QbProg | last post by:
Hello, what I'm saying here is about VS 2005 WITHOUT service pack. I have two DLL projects, with EXACTLY the same project preferences and settings. Both have alignment set to "default", it...
3
by: gentsquash | last post by:
I'm trying to display a paragraph that has a centered phrase, such as this one, in the middle of the paragraph. An example is the section "End of semester project" on my course-page ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.